from pprint import pprint
from datetime import datetime
import requests


def convert2ampm(time24: str) -> str:
    return datetime.strptime(time24, '%H:%M').strftime('%I:%M%p')


with open('buzzers.csv') as data:
    ignore = data.readline()
    flights = {}
    for line in data:
        k, v = line.strip().split(',')
        flights[k] = v
pprint(flights)

flights2 = {convert2ampm(k): v.title() for k, v in flights.items()}
pprint(flights2)


data = [1, 2, 3, 4, 5, 6, 7, 8]
evens = [num for num in data if not num % 2]
# print(evens)

data = [1, 'one', 2, 'two', 3, 'three', 4, 'four']
words = [num for num in data if isinstance(num, str)]
# print(words)

data = list('So long and thanks for all the fish'.split())
title = [word.title() for word in data]
# print(title)

fts = {convert2ampm(k): v.title() for k, v in flights.items()}

when = {dest: [k for k, v in fts.items() if v == dest]
        for dest in set(fts.values())}
pprint(when)


urls = ('https://litres.ru', 'https://google.ru')

def gen_from_urls(urls: tuple) -> tuple:
    for resp in (requests.get(url) for url in urls):
        yield len(resp.content), resp.status_code, resp.url

for resp_len, status, url, in gen_from_urls(urls):
    print(resp_len, '->', status, '->', url)
